import Vue from 'vue'

import BcIcon from './icon/index.js'
import BcButton from './button/index.js'
import BcButtonGroup from './button-group/index.js'
import BcToast from './toast/index.js'
import BcLoading from './loading/index.js'
import BcInput from './input/index.js'
import BcInputNumber from './input-number/index.js'
import { BcSelect, BcOption } from './select/index.js'
import DomPortal from './directive/vue-dom-portal.js'
import BcPopover from './popover/index.js'
import BcDatePicker from './date-picker/index.js'
import { BcCheckbox, BcCheckboxGroup } from './checkbox/index.js'
import BcTree from './tree/index.js'
import BcSlider from './slider/index.js'

const components = [
  BcIcon,
  BcButton,
  BcButtonGroup,
  BcToast,
  BcLoading,
  BcInput,
  BcInputNumber,
  BcSelect,
  BcOption,
  BcPopover,
  BcDatePicker,
  BcCheckbox,
  BcCheckboxGroup,
  BcTree,
  BcSlider
]

const install = function (Vue) {
  components.map(item => Vue.component(item.name, item));
}

if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue)
}

Vue.prototype.$toast = BcToast;

Vue.use(DomPortal)

export default install